class User < ActiveRecord::Base
  belongs_to :user_source
  has_many :advertisments
  belongs_to :user_type
  has_many :queries
  has_one   :pincode

  has_many :profiles
  serialize :user_interests
  
#  validates_format_of :email,
#                    :with =>  /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i,
#                    :message => "Its not a valid format"
#  validates_uniqueness_of :name, :message => "username already exists"
#  validates_confirmation_of :password, :message=>"Password doesn't match"

  def self.authenticate(user_info)
      find_by_name_and_password(user_info[:name], user_info[:password])
  end
end
